package com.jake.microservice.provider.jpa.service.impl;

import com.jake.microservice.provider.jpa.entity.UserEntity;
import com.jake.microservice.provider.jpa.repository.UserRepository;
import com.jake.microservice.provider.jpa.service.UserService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

@Service
public class UserServiceImpl implements UserService {

    @Autowired
    private UserRepository userRepository;

    @Override
    public List<UserEntity> findUsers() {
        return userRepository.findAll();
    }

    @Override
    public UserEntity findUserById(Integer uid) {
        return userRepository.findById(uid).orElse(null);
    }

    @Override
    public List<UserEntity> findUsersByName(String name) {
        return userRepository.findByUserName(name);
    }
}
